package com.alan.wifishare.view.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.RadioButton;

import com.alan.wifishare.R;

/**
 * @className: ALRadioButton
 * @describtion: ALRadioButton
 * @author: AlanWang
 * @email: 850267876@qq.com
 * @time: 2016/4/25 19:45
 */
public class ALRadioButton extends RadioButton {

    private int mDrawableSize;// xml文件中设置的大小

    public ALRadioButton(Context context) {
        super(context);
    }

    public ALRadioButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context, attrs);
    }

    public ALRadioButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initView(context, attrs);
    }

    private void initView(Context context, AttributeSet attrs) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ALRadioButton);
        mDrawableSize = a.getDimensionPixelSize(R.styleable.ALRadioButton_alDrawableSize, 50);
        a.recycle();

        Drawable[] mDrawables = getCompoundDrawables();
        mDrawables[1].setBounds(0, 0, mDrawableSize, mDrawableSize);
        setCompoundDrawables(mDrawables[0], mDrawables[1], mDrawables[2], mDrawables[3]);
    }

}
